﻿using Coldairarrow.Business.Base_leasesystem_accountrecharge;
using Coldairarrow.Entity.Base_leasesystem_accountrecharge;
using Coldairarrow.IBusiness;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Base_leasesystem_accountrecharge
{
    /// <summary>
    /// 充值记录控制器
    /// </summary>
    [Route("/Base_leasesystem_accountrecharge/[controller]/[action]")]
    [OpenApiTag("充值记录控制器")]
    public class leasesystem_accountrechargeController : BaseApiController
    {
        #region DI

        public leasesystem_accountrechargeController(Ileasesystem_accountrechargeBusiness leasesystem_accountrechargeBus,IOperator @operator)
        {
            _leasesystem_accountrechargeBus = leasesystem_accountrechargeBus;
            _operator = @operator;
        }

        Ileasesystem_accountrechargeBusiness _leasesystem_accountrechargeBus { get; }
        readonly IOperator _operator;

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<leasesystem_accountrecharge>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _leasesystem_accountrechargeBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<object> GetHeightSearch(PageInput<ConditionDTO> input) 
        {
            return await _leasesystem_accountrechargeBus.GetHeightSearch(input);
        }

        [HttpPost]
        public async Task<leasesystem_accountrecharge> GetTheData(IdInputDTO input)
        {
            return await _leasesystem_accountrechargeBus.GetTheDataAsync(input.id);
        }

        [HttpPost]
        public async Task<object> GetAccountInfo(PageInput<ConditionDTO> input)
        {
            return await _leasesystem_accountrechargeBus.GetAccountInfo(input,_operator.UserId);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(leasesystem_accountrecharge data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);
                data.BusinessOrderNo = IdHelper.GetId();
                await _leasesystem_accountrechargeBus.AddDataAsync(data);
            }
            else
            {
                await _leasesystem_accountrechargeBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        [ApiPermission("accountrecharge.Delete")]
        public async Task DeleteData(List<string> ids)
        {
            await _leasesystem_accountrechargeBus.DeleteDataAsync(ids);
        }

        /// <summary>
        /// 查询充值管理数据表格
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<object> GetDataList1(PageInput<ConditionDTO> input)
        {
            return await _leasesystem_accountrechargeBus.GetDataList(input);
        }

        #endregion
    }
}